import { Body, Controller, Get, Param, Post } from '@nestjs/common';
import { DbResourceService } from './dbResource.service';
import { GetDbResourcePageDto, AddDbResourceDto, UpdateDbResourceDto } from './dbResource.dto'

@Controller('admin/resource')
export class DbResourceController {
  constructor(private readonly dbResourceService: DbResourceService) { }

  @Get('page')
  getDbResourcePage(@Param() getDbResourcePageDto: GetDbResourcePageDto) {
    return this.dbResourceService.getDbResourcePage(getDbResourcePageDto)
  }

  @Post('save')
  addDbResource(@Body() addDbResourceDto: AddDbResourceDto) {
    return this.dbResourceService.addDbResource(addDbResourceDto)
  }

  @Post('update')
  updateDbResource(@Body() updateDbResourceDto: UpdateDbResourceDto) {
    return this.dbResourceService.updateDbResource(updateDbResourceDto)
  }

  @Post('delById/:id')
  deleteDbResource(@Param('id') id: string) {
    return this.dbResourceService.deleteDbResource(+id)
  }

  @Get(':id')
  getResourceInfo(@Param('id') id: string) {
    return this.dbResourceService.getResourceInfo(+id)
  }
}
